Skip to content

feat(fleet): port observe-agent fleet commands from Go CLI#17

Draft
beengud wants to merge 1 commit into
mainfrom
feat/fleet
Draft

feat(fleet): port observe-agent fleet commands from Go CLI#17
beengud wants to merge 1 commit into
mainfrom
feat/fleet

Conversation

@beengud

@beengud beengud commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Closes #3

Ported surface

Ports the observe fleet observe-agent monitoring commands from the deprecated Go CLI (cmd_fleet.go) to the TypeScript CLI.

Subcommand Description
fleet status Current agent inventory (host, env, version, auth result, instance id), newest first
fleet host <hostname> Event history for one host, incl. agent start time
fleet versions Version distribution across the fleet
fleet auth Auth-check status, failures first, incl. HTTP code + auth URL

All accept --window <duration> (Go duration strings: 20m, 24h, 168h; default 20m) and --format json|csv (default table).

How it reuses the existing query path

Fleet does not use meta CRUD. It runs OPAL against the Default.Observe Agent/Events dataset. Rather than porting the Go REST /v1/meta/export/query endpoint, this reuses the new CLI's existing OPAL execution path:

  • src/commands/fleet/run-query.ts builds a StageInput and calls the existing datasetQueryOutput GraphQL wrapper (src/gql/dataset/dataset-query-output.ts) — the same path src/commands/query.ts uses.
  • The one difference from query.ts: fleet targets the dataset by path via InputDefinitionInput.datasetPath (Default.Observe Agent/Events) instead of resolving a dataset ID, so no getDataset lookup is needed.
  • Column order and row sorting are carried by the OPAL pick_col/sort operators (ported verbatim from Go), so output matches the Go CLI.
  • Result parsing (transpose column-major paginatedResults, schema field types, table coloring) mirrors query.ts.

The four OPAL pipelines in src/commands/fleet/pipelines.ts are ported verbatim from cmd_fleet.go. The time window matches Go exactly: end = now-15s truncated to the minute, start = end - window.

Verification

  • Codegen: bun graphql-code-generator --config cg.tmp.config.ts✔ Generate (scoped to dataset ops; confirmed InputDefinitionInput.datasetPath exists in generated SDL).
  • Scoped tsc: bunx tsc --noEmit -p tsconfig.tmp.json → no errors in src/commands/fleet (only bun:test module-resolution noise in test files, expected).
  • Tests: bun test src/commands/fleet/13 pass, 0 fail (parseDuration, getFleetTimeRange, runFleetQuery input/parsing/error, and status/host command json/csv/table/error-exit).

🤖 Generated with Claude Code

Add `observe fleet` with status, host, versions, and auth subcommands,
mirroring the Go CLI's OPAL queries against `Default.Observe Agent/Events`.
Reuses the existing OPAL query path (datasetQueryOutput / StageInput) via a
dataset-path input instead of the Go REST export endpoint. Supports
--window (Go duration) and --format json|csv; preserves Go column order
and sorting.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port fleet observe-agent monitoring from the Go fork

2 participants